package com.cq.hd.app.controller;

import com.cq.hd.common.annotation.LoginUser;
import com.cq.hd.common.entity.AppLoginUser;
import com.cq.hd.common.pagination.Page;
import com.cq.hd.common.response.Result;
import com.cq.hd.product.api.TbActiveRedPacketApi;
import com.cq.hd.product.api.TbActiveRedPacketBillApi;
import com.cq.hd.product.api.dto.ActiveRedPacketBillPageDto;
import com.cq.hd.product.api.dto.ReceiveRedPacketDto;
import com.cq.hd.product.api.vo.ActiveRedPacketBillPageVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

@RestController
@RequestMapping("/activeRedPacket")
@Api(tags = "活动红包相关接口")
public class ActiveRedPacketController {

    @Autowired
    private TbActiveRedPacketApi activeRedPacketApi;

    @Autowired
    private TbActiveRedPacketBillApi activeRedPacketBillApi;

    @ApiOperation(value = "领取红包")
    @ApiImplicitParam(name = "receiveRedPacketDto", value = "实体", paramType = "body", dataType = "ReceiveRedPacketDto")
    @PostMapping("/receive")
    public Result<Boolean> receive(@ApiIgnore @LoginUser AppLoginUser appLoginUser, @RequestBody ReceiveRedPacketDto receiveRedPacketDto) {
        receiveRedPacketDto.setUserId(appLoginUser.getUserId());
        return activeRedPacketApi.receive(receiveRedPacketDto);
    }

    @ApiOperation(value = "红包领取列表")
    @ApiImplicitParam(name = "activeRedPacketBillPageDto", value = "实体", paramType = "query", dataType = "ActiveRedPacketBillPageDto")
    @ApiResponse(response = ActiveRedPacketBillPageVo.class, code = 200, message = "接口返回对象参数")
    @GetMapping("/pageReceive")
    public Result<Page<ActiveRedPacketBillPageVo>> pageReceive(@ApiIgnore @LoginUser AppLoginUser appLoginUser, ActiveRedPacketBillPageDto activeRedPacketBillPageDto) {
        activeRedPacketBillPageDto.setUserId(appLoginUser.getUserId());
        return activeRedPacketBillApi.pageReceive(activeRedPacketBillPageDto);
    }

}
